package com.fdb.efp.nls.service.impl.bd;

import com.fdb.basic.framework.core.constant.BaseConstant;
import com.fdb.efp.nls.service.facade.bd.FailureCreditAgreementService;
import com.fdb.efp.nls.service.facade.PubSysInfoService;
import com.fdb.efp.limit.service.facade.LmtPrdContService;
import com.fdb.efp.nls.service.facade.sx.NlsCreditInfoService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

/**
 * 失效 超过授信协议到期的记录: <br>
 * <p>
 * 0.1:caoxin:2019/4/14 20:55: TODO: <br>
 *
 * @author caoxin
 * @version 0.1
 * @date 2019/4/14 20:55
 * @since 2019/4/14 20:55
 */
@Service("bdFailureCreditAgreementService")
public class FailureCreditAgreementServiceImpl implements FailureCreditAgreementService {

    private  Logger logger = LoggerFactory.getLogger("FailureCreditAgreementServiceImpl");

    private final String msgTemplate = "message { }";
    @Autowired
    @Qualifier("lmtPrdContService")
    private LmtPrdContService lmtPrdContService;

    @Autowired
    @Qualifier("nlsCreditInfoService")
    private NlsCreditInfoService nlsCreditInfoService;

    @Autowired
    private PubSysInfoService pubSysInfoService;

    /**
     * 失效超过授信协议到期的记录: <br>
     *
     * 0.1:caoxin:2019/4/14 21:05: TODO: <br>
     * @author caoxin
     * @return
     * @since 2019/4/14 21:05
     * @date 2019/4/14 21:05
     * @version 0.1
     */

    @Override
    public Boolean inValidLmtProContOverExpireDate() {
        //获取当前的营业日期
        String openday = pubSysInfoService.getOpenday(BaseConstant.SYS_ID_1001);
        if (StringUtils.isEmpty(openday)) {
            logger.error("获取到的营业日期为空");
            return false;
        }
        String msg = "=====>失效超过授信协议到期的记录开始<=====";
        logger.info(msg,msgTemplate);
        int num = lmtPrdContService.inValidLmtProContOverExpireDate(openday+ " 00:00:01");
        String msg1 = "=====>失效超过授信协议到期的记录:"+num+"条<=====";
        logger.info(msg1,msgTemplate);
         num = nlsCreditInfoService.inValidLmtProContOverExpireDate(openday);
         msg1 = "=====>失效超过授信申请到期的记录:"+num+"条<=====";
        logger.info(msg1,msgTemplate);
        return true;
    }
}
